﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Sharp.DataTransferObject;
using Sharp.Portal;
using Sharp.Portal.ExtNet;
using Sharp.Portal.Mvc;
using Sharp.Portal.Mvc.Form;
using Sharp.Portal.Mvc.Models;

#endregion

namespace Sharp.WebBooter.Areas.Platform.Models
{
    /// <summary>
    /// 用户
    /// </summary>
    [ItemPage(Width = 1000, OpenWith = OpenWith.Window2Column)]
    public class UserViewModel : BaseViewModel, ISharpForm
    {
        public UserViewModel()
        {
            Profile = new UserProfileViewModel();
            Person = new EmployeeModel();
            UI = new ExtSharpFrom(this);
        }

        [HiddenInput]
        public int Id { get; set; }
        /// <summary>
        /// 获取或设置当前客户的用户名。
        /// </summary>
        [Display(Name = "用户名", Order = 0), Required]
        public string UserName { get; set; }

        [Display(Name = "电子邮件", Order = 1)]
        public string EMail { get; set; }

        /// <summary>
        /// 获取或设置当前客户的登录密码。
        /// </summary>
        [Display(Name = "密码", Order = 3, Prompt = "如果输入密码则密码重置"), DataType(DataType.Password)]
        public string Password { get; set; }

        /// <summary>
        /// 获取或设置当前客户的登录确认密码。
        /// </summary>
        [Display(Name = "确认密码", Order = 4, Prompt = "如果输入密码则密码重置")]
        [DataType(DataType.Password)]
        public string ConfirmPassword { get; set; }

        /// <summary>
        /// 是否锁定
        /// </summary>
        [Display(Name = "是否锁定", Order = 6)]
        public bool IsLockedOut { get; set; }
        /// <summary>
        /// 是否激活
        /// </summary>
        [Display(Name = "是否激活", Order = 6)]
        public bool IsApproved { get; set; }

        /// <summary>
        /// 密码问题
        /// </summary>
        [StringLength(255)]
        public string PasswordQuestion { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        /// <value>备注</value>
        [StringLength(255), Display(Name = "备注"), DataType(DataType.MultilineText)]
        public string Comment { get; set; }

        #region 方法

        /// <summary>
        /// 返回表示当前Object的字符串。
        /// </summary>
        /// <returns>表示当前对象的字符串。</returns>
        public override string ToString()
        {
            return UserName;
        }

        #endregion

        /// <summary>
        /// 角色Id
        /// </summary>
        [Display(Name = "角色", Order = 5), CustomField(FieldType.DropDownList, "Name", "Id", nameof(RoleList))]
        public IEnumerable<int> RoleIds { get; set; }
        /// <summary>
        /// 上面的数据源
        /// </summary>
        public IEnumerable<RoleDTO> RoleList { get; set; }

        [Section("扩展信息")]
        public UserProfileViewModel Profile { get; set; }
        public SharpFrom UI { get; set; }

        public partial class UserProfileViewModel
        {
            /// <summary>
            /// 主键
            /// </summary>
            public int Id { get; set; }
            /// <summary>
            /// QQ
            /// </summary>
            [Display(Name = "QQ")]
            public string QQ { get; set; }
            /// <summary>
            /// 微信
            /// </summary>
            [Display(Name = "微信")]
            public string Wechart { get; set; }
            /// <summary>
            ///     获取或设置用户账户注册的时间。
            /// </summary>
            public DateTime RegisteredTime { get; set; }

            /// <summary>
            ///     获取或设置成员资格用户的特定于应用程序的信息
            /// </summary>
            /// <value>成员资格用户的特定于应用程序的信息</value>
            public string Comment { get; set; }

            /// <summary>
            ///     获取一个值，该值指示成员资格用户是否因被锁定而无法进行验证。
            /// </summary>
            /// <value>如果成员资格用户因被锁定而无法进行验证，则为 true；否则为 false。</value>
            public bool IsLockedOut { get; set; }

            /// <summary>
            /// 是否审核
            /// </summary>
            public bool IsApproved { get; set; }

            /// <summary>
            ///     获取一个值，表示用户当前是否联机。
            /// </summary>
            public bool IsOnline { get; set; }

            /// <summary>
            /// 成员资格用户上次进行身份验证或访问应用程序的日期和时间
            /// </summary>
            public DateTime? LastActivityDate { get; set; }

            /// <summary>
            ///  最近一次锁定成员资格用户的日期和时间
            /// </summary>
            public DateTime? LastLockoutDate { get; set; }

            /// <summary>
            ///     获取上次更新成员资格用户的密码的日期和时间
            /// </summary>
            public DateTime? LastPasswordChangedDate { get; set; }

            /// <summary>
            ///     密码问题
            /// </summary>
            public string PasswordQuestion { get; set; }

            /// <summary>
            /// 失败重试次数
            /// </summary>
            public int AccessFailedCount { get; set; }

        }

        [Section("员工信息")]
        public EmployeeModel Person { get; set; }
        [HiddenInput]
        public int EmployeeId { get; internal set; }

    }

}